package com.vf.user.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.vf.common.annotation.Log;
import com.vf.common.core.controller.BaseController;
import com.vf.common.core.domain.AjaxResult;
import com.vf.common.enums.BusinessType;
import com.vf.user.domain.CreditHistory;
import com.vf.user.service.ICreditHistoryService;
import com.vf.common.utils.poi.ExcelUtil;
import com.vf.common.core.page.TableDataInfo;

/**
 * 信用分变更记录Controller
 * 
 * @author LBS
 * @date 2025-06-04
 */
@RestController
@RequestMapping("/user/creditHistory")
@Api(tags="信用分变更记录")
public class CreditHistoryController extends BaseController
{
    @Autowired
    private ICreditHistoryService creditHistoryService;

    /**
     * 查询信用分变更记录列表
     */
    @PreAuthorize("@ss.hasPermi('user:creditHistory:list')")
    @GetMapping("/list")
    public TableDataInfo list(CreditHistory creditHistory)
    {
        startPage();
        List<CreditHistory> list = creditHistoryService.selectCreditHistoryList(creditHistory);
        return getDataTable(list);
    }

    /**
     * 导出信用分变更记录列表
     */
    @PreAuthorize("@ss.hasPermi('user:creditHistory:export')")
    @Log(title = "信用分变更记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CreditHistory creditHistory)
    {
        List<CreditHistory> list = creditHistoryService.selectCreditHistoryList(creditHistory);
        ExcelUtil<CreditHistory> util = new ExcelUtil<CreditHistory>(CreditHistory.class);
        util.exportExcel(response, list, "信用分变更记录数据");
    }

    /**
     * 获取信用分变更记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('user:creditHistory:query')")
    @GetMapping(value = "/{historyId}")
    public AjaxResult getInfo(@PathVariable("historyId") Long historyId)
    {
        return success(creditHistoryService.selectCreditHistoryByHistoryId(historyId));
    }

    /**
     * 新增信用分变更记录
     */
    @PreAuthorize("@ss.hasPermi('user:creditHistory:add')")
    @Log(title = "信用分变更记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CreditHistory creditHistory)
    {
        return toAjax(creditHistoryService.insertCreditHistory(creditHistory));
    }

    /**
     * 修改信用分变更记录
     */
    @PreAuthorize("@ss.hasPermi('user:creditHistory:edit')")
    @Log(title = "信用分变更记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CreditHistory creditHistory)
    {
        return toAjax(creditHistoryService.updateCreditHistory(creditHistory));
    }

    /**
     * 删除信用分变更记录
     */
    @PreAuthorize("@ss.hasPermi('user:creditHistory:remove')")
    @Log(title = "信用分变更记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{historyIds}")
    public AjaxResult remove(@PathVariable Long[] historyIds)
    {
        return toAjax(creditHistoryService.deleteCreditHistoryByHistoryIds(historyIds));
    }
}
